For a quick start, we can use the existing ROS plugin package, pluginlib_calculator. If we want to create this package from scratch, we can use the following command:
catkin_create_pkg pluginlib_calculator pluginlib rosecpp std_msgs
The main dependency of this package is pluginlib. We can discuss the main source files in this package to build plugins. However, you can get the plugin code from the code provided with this book or download it at this link:
git clone https://github.com/jocacace/plugin_calculator
If the package is built properly, we can execute the loader. The following command will query the plugins inside a package:
rospack plugins --attrib=plugin pluginlib_calculator
After launched the roscore, we can execute the calculator_loader using the following command:
rosrun pluginlib_calculator calculator_loader
We can create a package called nodelet_hello_world, using the following command to create our nodelet:
catkin_create_pkg nodelet_hello_world nodelet roscpp std_msgs
Otherwise, we can use the existing package from nodelet_hello_world, or download it from the following link:
git clone https://github.com/jocacace/nodelet_hello_world
The following commands can start the nodelet manager:
Start roscore:roscore
Start the nodelet manager, using the following command:
rosrun nodelet nodelet manager __name:=nodelet_manager
After launching the nodelet manager, we can start the nodelet by using the following command:
rosrun nodelet nodelet load nodelet_hello_world/Hello nodelet_manager
__name :=nodelet1
The following command publishes a string to /nodelet1/msg_in:
rostopic pub /nodelet1/msg_in std_msgs/String "Hello"
The preceding launch can be launched with the following command:
roslaunch nodelet_hello_world hello_world.launch
Open rqt_gui: rosrun rqt_gui rqt_gui
Alternatively, you can directly load the rqt_node plugin:
rosrun rqt_graph rqt_graph
Before starting development with Gazebo plugins, we might need to install some packages. So you might need to install its development package in Ubuntu using the following command:
sudo apt-get install libgazebo7-dev
Create a folder called gazebo_basic_world_plugin in a desired folder and create a CPP file called hello_world.cc:
mkdir gazebo_basic_world_plugin && cd gazebo_basic_world_plugin
nano hello_world.cc
Create a build folder for storing the shared object:
mkdir build && cd build
After switching to the buildfolder, execute the following command to compile and build the source code:
cmake ../
make
This file is also contained in the code provided with this book and in the following Git repository:
git clone https://github.com/jocacace/gazebo_basic_world_plugin
Run the Gazebo server and load this world file:
cd gazebo_basic_world_plugin
gzserver hello.world --verbose